import { http } from "@/utils/http";
/**
 *
 * @param params 用户列表-分页
 * @returns
 */
export function queryUserPage(params: Partial<ShopUserRequest & PageRequest>) {
  return http.get<MResponse<PageVo<Array<ShopUserVo>>>>("/user/queryUserPage", { params });
}

export function register(data: ShopUserRegisterRequest) {
  return http.post<MResponse>("/user/register", { data });
}

export function updateUser(data: ShopUserUpdateRequest) {
  return http.post<MResponse>("/user/updateUser", { data });
}

export function deleteUser(userId: number) {
  return http.post<MResponse>("/user/deleteUser", { data: { userId } });
}

export const getLogin = (data?: object) => {
  return http.postJson<MResponse<UserResult>>("/auth/login", { data });
};

/** 刷新`token` */
export const refreshTokenApi = (data?: object) => {
  return http.post<MResponse<RefreshTokenResult>>("/auth/refreshToken", {
    data
  });
};
